import { Timer } from "@sapi-game/gameComponent/common/timer/timer";
import { GameComponent } from "@sapi-game/main";
import { PKBuildState } from "../buildState";

export class PKBuildDaemonComponent extends GameComponent<PKBuildState> {
    override onAttach(): void {
        const timer = this.state.getComponent(Timer);
        this.subscribe(timer.events.tick, (t) => {
            this.context.blue.team.actionbar(
                `§b[你是蓝队] §r建筑剩余时间 : §6§l${t.remainingTime}§r 秒`
            );
            this.context.red.team.actionbar(
                `§c[你是红队] §r建筑剩余时间 : §6§l${t.remainingTime}§r 秒`
            );
        });
    }
}
